<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

return new class extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create("message_list", function (Blueprint $table) {
            $table->id();
            $table->string("content")->comment("消息内容");
            $table->integer("type")->comment("消息类型");
            $table->json("other_content")->comment("消息附属内容");
            $table->integer("value")->virtualAs("other_content->'$.value'")->comment("消息价值 ￥")->nullable();
            $table->integer("external_users_id")->default(-1)->comment("所属用户为ID 对应 external_users 表 -1 表示找不到对应用户");
            $table->softDeletesTz()->comment("软删字段");
            $table->timestamps();
            $table->index("external_users_id", "external_users_id");
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists("message_list");
    }
};
